package scraper;

import java.io.BufferedWriter;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;

public class Desambiguacion {

	private String dirPython;
	private Process ipython;
	private ProcessBuilder builder;
	private PrintWriter writer;
	private String ls;

	public Desambiguacion(Configuracion config) throws IOException {
		dirPython = config.getDirPython();
		String ipythonBin = "ipython";
		builder = new ProcessBuilder(dirPython + ipythonBin);
		builder.directory(new File("/home/jairo/PycharmProjects/wikiparser/"));
		builder.redirectErrorStream(true);
		ipython = builder.start();
		OutputStream entradaPython = ipython.getOutputStream();
		writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(entradaPython)));
		ls = System.lineSeparator();
		writer.print("from calcular_similitud import *" + ls);
		writer.flush();
//		int returnCode = -1;
//		try {
//			returnCode = ipython.waitFor();
//		} catch (InterruptedException ex) {
//			System.out.println(ex);
//		}
	}
	
	public void taggear(){
		writer.print("taggear_archivo()" + ls);
		writer.flush();
	}

}
